package hmis.pos.Common.Util;

import hmis.pos.Common.vo.ReportForm.RoomStatistics;

import javax.persistence.MappedSuperclass;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: hmis
 * @description: 用于处理营业额数据和预订天数数据调用相同的方法
 * @author: PTY
 * @create: 2019-05-22 23:12
 **/
@MappedSuperclass
public class TurnoverAndReservationAmount {

    //月报表数据转化为季度报表数据
    public static List<List<RoomStatistics>>  monthToSeason(List<List<RoomStatistics>> monthData){

        //定义季度报表List
        List<List<RoomStatistics>> seasonData = new ArrayList<>();

        //循环处理月度营业额数据转换为季度营业额数据
        int season = 1;
        for(int i=0;i<12;i+=3,season++){
            List<RoomStatistics> roomStatisticsList1 = monthData.get(i);
            List<RoomStatistics> roomStatisticsList2 = monthData.get(i+1);
            List<RoomStatistics> roomStatisticsList3 = monthData.get(i+2);

            List<RoomStatistics> seasonRoomStatisticsList = new ArrayList<>();

            for(int j=0;j<roomStatisticsList1.size();j++){
                if(j==0){
                    seasonRoomStatisticsList.add(new RoomStatistics("state",season));
                }else{
                    double totalValue = roomStatisticsList1.get(j).getValue()+roomStatisticsList2.get(j).getValue()+roomStatisticsList3.get(j).getValue();
                    seasonRoomStatisticsList.add(new RoomStatistics(roomStatisticsList1.get(j).getType(),totalValue));
                }
            }

            seasonData.add(seasonRoomStatisticsList);
        }

        return seasonData;

    }
}
